<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<link rel="stylesheet" href="css/background.css">
<script type="text/javascript" src="jq/jquery-3.7.1.js"></script>
<body>
<form action="FenYeShopServlet" method="get" id="forms">

 <div id="right_div">
             id<input type="text" name="shopId" id="shopId">
		          商品名<input type="text" name="shopName" id="shopName">
		          商品地址<input type="text" name="shopUrl" id="shopUrl">
		          商品价格<input type="text" name="shopPrice" id="shopPrice">
		          商品状态<input type="text" name="shopType" id="shopType">
		          
            <input type="button" value="搜索" id="enterSouShuo">
            <input type="button" value="添加商品" id="addShop">
            <table id="showTable">
            <tr>
 				<td>id</td>
 				<td>商品名</td>
 				<td>商品地址</td>
 				<td>商品价格</td>
 				<td>商品状态</td>
 				<td>操作1</td>
 				<td>操作2</td>
 				</tr>
            <c:forEach items="${PageBean.data }" var="ss" varStatus="status">
 				<tr id='showShop'>
 				<td id='sId'>${ss.sId}</td>
 				<td id='sName'>${ss.sName}</td>
 				<td id='sUrl'>${ss.sUrl}</td>
 				<td id='sPrice'>${ss.sPrice}</td>
 				<td id='sType'>${ss.sType}</td>
 				<td><a href="UserDeleteServlet?userId=${ss.sId }&tableName=shopdingdong&tableId=sId">删除</a></td>
 				<td><a href='updateShop.jsp?shopId=${ss.sId }&shopName=${ss.sName}&shopUrl=${ss.sUrl }&shopPrice=${ss.sPrice }&shopType=${ss.sType }'>修改</a></td>
 				</tr>
 				</c:forEach>
            </table>
            <h2>
				<a href="FenYeShopServlet?currentPageNum=1&&pageSize=5">第一页</a>
				<a href="FenYeShopServlet?currentPageNum=${PageBean.currentPageNum-1 }&&pageSize=5">上一页</a>
				<a href="FenYeShopServlet?currentPageNum=${PageBean.currentPageNum+1 }&&pageSize=5">下一页</a>
				<a href="FenYeShopServlet?currentPageNum=${PageBean.pageNum }&&pageSize=5">最后一页</a>
			</h2>
			<br><br>
			<h2>
				总页码${PageBean.pageNum }页， 当前第${PageBean.currentPageNum }页，总共有${PageBean.count }条记录
			</h2>
        </div>
        </form>
</body>
<script type="text/javascript">
		$("#enterSouShuo").click(function(){
			var  url=$("#forms");
			url[0].action="selectByShopServlet";
			console.log(url[0].action);
			$("#forms").submit();
		});
		
		
		$("#addShop").click(function(){
				if($("input[name=shopName]").val()==""){
					alert("商品名未填写！！！");
				}
				else if($("input[name=shopUrl]").val()==""){
					alert("商品url路径未填写！！！");
				}
				else if($("input[name=shopPrice]").val()==""){
					alert("商品价格未填写！！！");
				}
				else if($("input[name=shopType]").val()==""){
					alert("商品类型未填写！！！");
				}else{
					var  url=$("#forms");
					url[0].action="addShopServlet";
					$("#forms").submit();
				}
		});

</script>
</html>